//
//  MRDTableView.m
//  MRDClient
//
//  Created by laomi on 2019/3/6.
//  Copyright © 2019年 laomi. All rights reserved.
//

#import "MRDTableView.h"
#import "LYEmptyView.h"
#import "UIView+Empty.h"

@interface MRDTableView()
@property(nonatomic,strong)UIView *private_ly_emptyView;
@property(nonatomic,strong)UIView *private_ly_errorView;
@end

@implementation MRDTableView

-(instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self setup];
    }
    return self;
}
-(instancetype)init
{
    self = [super init];
    if (self) {
        [self setup];
    }
    return self;
}
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}

-(void)setup
{
    self.tableFooterView = [UIView new];
    self.separatorInset = UIEdgeInsetsMake(0, 12, 0, 12);
    //F4f5f9
    self.backgroundColor = [UIColor colorWithRed:244/255.0 green:245/255.0 blue:249/255.0 alpha:1];
    self.showsVerticalScrollIndicator = NO;
   
}
-(void)showErrorViewWithImage:(UIImage*)image title:(NSString*)title detailTitle:(NSString*)detailString btnTitle:(NSString*)btnTitle onClickBlock:(LAOMIEmpteyErrorBlock)block;
{
    __weak typeof(self)weallself = self;
    LYEmptyView *v = [LYEmptyView emptyActionViewWithImage:image titleStr:title detailStr:detailString btnTitleStr:btnTitle btnClickBlock:^{
        if (block) {
            block(weallself);
        }
    }];
    v.titleLabFont = [UIFont systemFontOfSize:16];
    v.titleLabTextColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1];
    self.ly_emptyView = v;
    self.private_ly_errorView = v;
    [self ly_showEmptyView];
}
-(void)showErrorView
{
    
}
-(void)hiddenErrorView;
{
    if (self.private_ly_errorView) {
        self.ly_emptyView = self.private_ly_errorView;
    }else{
        
    }
    [self ly_showEmptyView];
}

-(void)showEmptyViewWithImage:(UIImage*)image title:(NSString*)title detailTitle:(NSString*)detailString btnTitle:(NSString*)btnTitle onClickBlock:(LAOMIEmpteyErrorBlock)block;{
    __weak typeof(self)weallself = self;
    LYEmptyView *v = [LYEmptyView emptyActionViewWithImage:image titleStr:title detailStr:detailString btnTitleStr:btnTitle btnClickBlock:^{
        if (block) {
            block(weallself);
        }
    }];
    v.titleLabFont = [UIFont systemFontOfSize:16];
    v.titleLabTextColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1];
    self.ly_emptyView = v;
    self.private_ly_emptyView = v;
    [self ly_showEmptyView];
}
-(void)showEmptyView
{
    if (self.private_ly_emptyView) {
        self.ly_emptyView = self.private_ly_emptyView;
    }else{
        
    }
    [self ly_showEmptyView];
}
-(void)hiddenEmptyView;
{
    self.ly_emptyView = nil;
    [self ly_hideEmptyView];
 
}
-(void)layoutSubviews
{
    [super layoutSubviews];
}
@end
